package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.OrgBindAccountInfo;
import cc.mrbird.febs.power.service.IOrgBindAccountInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/org-bind-account-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class OrgBindAccountInfoController {

    private final IOrgBindAccountInfoService iOrgBindAccountInfoService;

    /**
     * 根据组织获取绑定的账户
     * @param orgId
     * @return
     */
    @GetMapping("/info/{orgId}")
    public R getOrgByAccountId(@PathVariable("orgId") Integer orgId) {
        return R.ok(iOrgBindAccountInfoService.getOrgByAccountId(orgId));
    }

    /**
     * 新增组织机构绑定权限
     * @param orgBindAccountInfo
     * @return
     */
    @PostMapping("/OrgBindAccountInfoAdd")
    public R OrgBindAccountInfoAdd(OrgBindAccountInfo orgBindAccountInfo) {
        return R.ok(iOrgBindAccountInfoService.save(orgBindAccountInfo));
    }

    /**
     * 修改组织机构绑定权限
     * @param orgBindAccountInfo
     * @return
     */
    @PutMapping("/OrgBindAccountInfoEdit")
    public R OrgBindAccountInfoEdit(OrgBindAccountInfo orgBindAccountInfo) {
        return R.ok(iOrgBindAccountInfoService.updateById(orgBindAccountInfo));
    }

    /**
     * 通过ID删除一条记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R OrgBindAccountInfoDel(@PathVariable Integer id) {
        return R.ok(iOrgBindAccountInfoService.removeById(id));
    }

}
